package cn.tannn.cat.file.sdk.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * 存储器状态 master: use  slave: no use
 *
 * @author <a href="https://tannn.cn/">tan</a>
 * @date 2024/3/7 13:31
 */
@AllArgsConstructor
@Getter
public enum StorageMaster {
    /**
     * 主
     */
    MASTER(1,"主"),

    /**
     * 从
     */
    SLAVE(0,"从");

    /**
     * 类型
     */
    private final int type;

    /**
     * 注释
     */
    private final String remark;

    /**
     * 获取枚举实例
     * @param type 类型
     * @return ConfigMaster
     */
    public static StorageMaster fromValue(Integer type) {
        for (StorageMaster master : StorageMaster.values()) {
            if (Objects.equals(type, master.getType())) {
                return master;
            }
        }
        throw new IllegalArgumentException();
    }
}
